import 'package:flutter/material.dart';

/// 应用颜色管理类
/// 统一管理浅色和深色主题的所有颜色定义
class AppColors {
  // 私有构造函数，防止实例化
  AppColors._();

  /// 浅色主题颜色
  static const _LightColors light = _LightColors();
  
  /// 深色主题颜色
  static const _DarkColors dark = _DarkColors();
  
  /// 根据主题亮度获取对应的颜色
  static _BaseColors of(BuildContext context) {
    return Theme.of(context).brightness == Brightness.light ? light : dark;
  }
}

/// 颜色基类
abstract class _BaseColors {
  const _BaseColors();
  
  // 主要颜色
  Color get primary;
  Color get primaryVariant;
  Color get secondary;
  Color get secondaryVariant;
  
  // 背景颜色
  Color get background;
  Color get surface;
  Color get scaffoldBackground;
  
  // 文本颜色
  Color get onPrimary;
  Color get onSecondary;
  Color get onBackground;
  Color get onSurface;
  Color get textPrimary;
  Color get textSecondary;
  Color get textHint;
  
  // 状态颜色
  Color get success;
  Color get warning;
  Color get error;
  Color get info;
  
  // 连接状态颜色
  Color get statusConnected;
  Color get statusConnecting;
  Color get statusDisconnected;
  
  // 开关和控件颜色
  Color get switchActiveTrack;
  Color get switchActiveThumb;
  Color get switchInactiveTrack;
  Color get switchInactiveThumb;
  
  // 按钮颜色
  Color get buttonPrimary;
  Color get buttonSecondary;
  Color get buttonDisabled;
  
  // 边框和分割线
  Color get divider;
  Color get border;
  
  // 卡片和容器
  Color get cardBackground;
  Color get containerBackground;
}

/// 浅色主题颜色定义
class _LightColors extends _BaseColors {
  const _LightColors();
  
  @override
  Color get primary => const Color(0xFF2196F3);
  
  @override
  Color get primaryVariant => const Color(0xFF1976D2);
  
  @override
  Color get secondary => const Color(0xFF03DAC6);
  
  @override
  Color get secondaryVariant => const Color(0xFF018786);
  
  @override
  Color get background => const Color(0xFFFAFAFA);
  
  @override
  Color get surface => Colors.white;
  
  @override
  Color get scaffoldBackground => Colors.white;
  
  @override
  Color get onPrimary => Colors.white;
  
  @override
  Color get onSecondary => Colors.black;
  
  @override
  Color get onBackground => const Color(0xFF212121);
  
  @override
  Color get onSurface => const Color(0xFF212121);
  
  @override
  Color get textPrimary => const Color(0xFF212121);
  
  @override
  Color get textSecondary => const Color(0xFF757575);
  
  @override
  Color get textHint => const Color(0xFF9E9E9E);
  
  @override
  Color get success => const Color(0xFF38A169);
  @override
  Color get warning => const Color(0xFFDD6B20);
  @override
  Color get error => const Color(0xFFE53E3E);
  @override
  Color get info => const Color(0xFF3182CE);
  
  @override
  Color get statusConnected => const Color(0xFF4CAF50);
  @override
  Color get statusConnecting => const Color(0xFFFF9800);
  @override
  Color get statusDisconnected => const Color(0xFF9E9E9E);
  
  @override
  Color get switchActiveTrack => const Color(0xFF81C784);
  
  @override
  Color get switchActiveThumb => const Color(0xFF4CAF50);
  
  @override
  Color get switchInactiveTrack => const Color(0xFFE0E0E0);
  
  @override
  Color get switchInactiveThumb => Colors.white;
  
  @override
  Color get buttonPrimary => const Color(0xFF2196F3);
  
  @override
  Color get buttonSecondary => const Color(0xFFE0E0E0);
  
  @override
  Color get buttonDisabled => const Color(0xFFBDBDBD);
  
  @override
  Color get divider => const Color(0xFFE0E0E0);
  
  @override
  Color get border => const Color(0xFFE0E0E0);
  
  @override
  Color get cardBackground => Colors.white;
  
  @override
  Color get containerBackground => const Color(0xFFF5F5F5);
}

/// 深色主题颜色定义
class _DarkColors extends _BaseColors {
  const _DarkColors();
  
  @override
  Color get primary => const Color(0xFF90CAF9);
  
  @override
  Color get primaryVariant => const Color(0xFF42A5F5);
  
  @override
  Color get secondary => const Color(0xFF80CBC4);
  
  @override
  Color get secondaryVariant => const Color(0xFF4DB6AC);
  
  @override
  Color get background => const Color(0xFF1E2329);
  
  @override
  Color get surface => const Color(0xFF2B3139);
  
  @override
  Color get scaffoldBackground => const Color(0xFF1E2329);
  
  @override
  Color get onPrimary => Colors.black;
  
  @override
  Color get onSecondary => Colors.black;
  
  @override
  Color get onBackground => Colors.white;
  
  @override
  Color get onSurface => Colors.white;
  
  @override
  Color get textPrimary => Colors.white;
  
  @override
  Color get textSecondary => const Color(0xFFBDBDBD);
  
  @override
  Color get textHint => const Color(0xFF757575);
  
  @override
  Color get success => const Color(0xFF48BB78);
  @override
  Color get warning => const Color(0xFFED8936);
  @override
  Color get error => const Color(0xFFF56565);
  @override
  Color get info => const Color(0xFF4299E1);
  
  @override
  Color get statusConnected => const Color(0xFF66BB6A);
  @override
  Color get statusConnecting => const Color(0xFFFFB74D);
  @override
  Color get statusDisconnected => const Color(0xFF757575);
  
  @override
  Color get switchActiveTrack => const Color(0xFF81C784);
  
  @override
  Color get switchActiveThumb => const Color(0xFF4CAF50);
  
  @override
  Color get switchInactiveTrack => const Color(0xFF424242);
  
  @override
  Color get switchInactiveThumb => const Color(0xFF757575);
  
  @override
  Color get buttonPrimary => const Color(0xFF90CAF9);
  
  @override
  Color get buttonSecondary => const Color(0xFF424242);
  
  @override
  Color get buttonDisabled => const Color(0xFF616161);
  
  @override
  Color get divider => const Color(0xFF3C434B);
  
  @override
  Color get border => const Color(0xFF3A3F47);
  
  @override
  Color get cardBackground => const Color(0xFF2B3139);
  
  @override
  Color get containerBackground => const Color(0xFF2C2C2C);
}